package top.ivansong.crawler.weather.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.ivansong.crawler.weather.bo.WeatherCNData;
import top.ivansong.crawler.weather.bo.WeatherHourlyCNData;
import top.ivansong.crawler.weather.bo.WeatherHourlyMJData;
import top.ivansong.crawler.weather.bo.WeatherMJData;
import top.ivansong.crawler.weather.support.FetchWeatherSupport;

import java.util.List;

/**
 * @author ivansong
 * @since 2018/2/23
 */
@RestController
@RequestMapping("/weather")
public class WeatherController {

    @Autowired
    private FetchWeatherSupport fetchWeatherSupport;

    @GetMapping("/hourly/cn")
    public List<WeatherHourlyCNData> weather() {
        return fetchWeatherSupport.fetchWeatherHourlyDataOfCN();
    }

    @GetMapping("/hourly/mj")
    public List<WeatherHourlyMJData> weatherHourlyMJ() {
        return fetchWeatherSupport.fetchWeatherHourlyDataOfMJ();
    }


    @GetMapping("/daily/cn")
    public List<WeatherCNData> dailyCNWeather() {
        return fetchWeatherSupport.fetchWeatherDataOfCN();
    }

    @GetMapping("/daily/mj")
    public List<WeatherMJData> dailyMJWeather() {
        return fetchWeatherSupport.fetchWeatherDataOfMJ();
    }
}
